<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <!--<link rel="icon" href="http://getbootstrap.com/favicon.ico">-->

    <title th:text="鸡天新闻-注册"></title>

    <!-- Bootstrap core CSS -->
    <link th:href="@{../static/css/bootstrap.min.css}" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link th:href="@{../static/css/signin.css}" rel="stylesheet">
</head>
<script type="text/javascript">
    function check() {
        var pwd1=document.registerForm.loginPwd.value;
        var pwd2=document.registerForm.loginPwd1.value;
        var loginName=document.registerForm.loginName.value;
        if (loginName.length<4){
            alert("用户名长度需大于等于4!");
            return false;
        }
        if (loginName.match(/^[a-zA-Z0-9]+$/)==null){
            alert("用户名只能包含字母和数字!");
            return false;
        }
        if (pwd1!==pwd2){
            alert("两次输入密码不相同!");
            return false;
        }
        if (pwd1.length<6){
            alert("密码长度需大于6!");
            return false;
        }
        return true;
    }
</script>

<body class="text-center">
<form name="registerForm" class="form-signin" th:action="@{~/register}" method="post" onsubmit="return check()">
    <img class="mb-4" th:src="@{../static/images/Snow.svg}" alt="" width="72" height="72" style="CURSOR: hand" onclick='window.location.href="/index"'>
    <h1 class="h3 mb-3 font-weight-normal">鸡 天 新 闻 -- 注 册</h1>
    <input type="text" for="loginName" name="loginName" class="form-control" placeholder="用户名" required="" autofocus="">
    <input type="text" for="userPhone" name="userPhone" class="form-control" placeholder="手机号" required="" autofocus="">
    <input type="email"  for="userEmail" name="userEmail" class="form-control" placeholder="邮箱地址" required="" autofocus="">
    <input type="password" for="loginPwd" name="loginPwd" class="form-control" placeholder="请输入密码" required="">
    <input type="password" id="loginPwd1" name="loginPwd1" class="form-control" placeholder="请再次输入密码" required="">
    <div class="checkbox mb-3">
    </div>
    <div class=" col-md-12" th:if="${registerError}">
        <p class="blog-label-error" style="color:red;" th:text="${errorMsg}"></p>
    </div>
    <button class="btn btn-lg btn-primary " style="width: 100px " type="submit">提 交</button>
    <button class="btn btn-lg btn-primary " style="width: 100px " type="button" onclick="window.location.href='/login'" >登 录</button>
    <p class="mt-5 mb-3 text-muted">© 2018-2019</p>
</form>
</body>
</html>